package de.iritgo.skillfull.component.visitor;

import de.iritgo.skillfull.component.motion.MoveFieldComponent;
import de.iritgo.skillfull.component.visual.SpriteSheetRenderComponent;

/**
 * Set in the specific components the move animation
 * 
 * @author held
 *
 */
public class MoveAnimationVisitor extends BaseVisitor 
{
	private boolean done;
	private boolean setDestToMoveAnimCmp;

	float rotation = -1;
	private int special;
	private boolean continuous;
	
	public MoveAnimationVisitor (boolean continuous)
	{
		this.done = false;
		this.continuous = continuous;
		this.setDestToMoveAnimCmp = true;
	}
	
	public MoveAnimationVisitor(int special) 
	{
		this.special = special;
	}

	public boolean isDone ()
	{
		return done;
	}
	public void visit (MoveFieldComponent moveFieldComponent) 
	{
		if (special == 1)
		{
			done = true;
			return;
		}
		
		if (moveFieldComponent.dstReached ())
		{
			done = true;
		}
	}

	public void visit(SpriteSheetRenderComponent spriteSheetRenderComponent)
	{
		if (special == 1 || done)
		{
			spriteSheetRenderComponent.stopAnimation ();
			done = true;
			return;
		}
		
		if (setDestToMoveAnimCmp)
		{
			spriteSheetRenderComponent.startAnimation (false, true, continuous);
			setDestToMoveAnimCmp = false;
		}
	}

}
